<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">

    <!-- Always force latest IE rendering engine -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- Mobile Specific Meta -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="DESCRIPTION">
    <meta name="keywords" content="KEYWORDS">
    <meta name="author" content="AUTHOR NAME">

    <!-- TITLE -->
    <title>Python数据列表</title>

    <!-- FAVICON -->
    <link href="../static/img/favicon.ico" rel="icon">

    <!-- BOOTSTRAP CSS -->
    <link rel="stylesheet" href="../static/css/bootstrap.min.css">

    <!-- FONT-AWESOME -->
    <link rel="stylesheet" href="../static/css/font-awesome-4.7.0/css/font-awesome.min.css">

    <!-- MAGNIFIC POPUP CORE CSS -->
    <link href="../static/css/magnific-popup.css" rel="stylesheet">

    <!-- OWL CAROUSEL -->
    <link href="../static/css/owl.carousel.min.css" rel="stylesheet">
    <link href="../static/css/owl.theme.default.min.css" rel="stylesheet">

    <!--Style CSS file-->
    <link rel=" stylesheet" href="../static/css/style.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 20px;
        }

        .pagination {
            display: inline-block;
            margin: 10px;
        }

        .pagination a {
            color: #000;
            padding: 8px 16px;
            text-decoration: none;
            transition: background-color 0.3s;
        }

        .pagination a:hover {
            background-color: #ddd;
        }

        .pagination .active {
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>

<body>

    <!-- ====== Preloader ======  -->
    <div id="loader-wrapper">
        <div id="loader"></div>
        <div class="loader-section section-left"></div>
        <div class="loader-section section-right"></div>
    </div>
    <!-- ======End Preloader ======  -->

    <!-- ======START NAVGITION ======  -->
    <nav class="navbar navbar-expand-lg">
        <!-- logo -->
        <a class="navbar-brand" href="#home">
            <img src="../static/img/logo.png" alt="header-Logo" class="logo"></a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText">
            <span class="icon-bar"><i class="fa fa-bars fa-2x"></i></span>
        </button>
        <!--End of Resposive Toggle icon-->

        <div class="collapse navbar-collapse" id="navbarText">
            <!--Main menu navigation list-->
            <ul class="navbar-nav ml-auto line">
                <li class="nav-item">
                    <a class="nav-link" href="/index">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" href="#movie">电影</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/score">评分</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/portfolio">词云</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/team">团队</a>
                </li>
            </ul>
            <!--End of Main menu navigation list-->
        </div>
        <!--End of resposive collapse class-->
    </nav>
    <!-- ====== END NAVGITION ======  -->
    <!-- ====== START GET READY ====== -->
    <section class="ready movie padding" id="movie" data-scroll-index="1">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 cta">
                    <div class="text-center">
                        <h2 class="heading-primary mb-3">豆瓣电影Top250电影</h2>
                        <table class="table table-striped">
                            <tr>
                                <td>排名</td>
                                <td>电影中文名</td>
                                <td>电影外文名</td>
                                <td>评分</td>
                                <td>评价人数</td>
                                <td>概述</td>
                                <td>其他信息</td>
                            </tr>
                            <tbody>
                                {% for item in datas %}
                                <tr>
                                    <td>{{ item[0] }}</td>

                                    <td><a href="{{ item[1] }}">{{ item[3] }}</a></td>

                                    <td>{{ item[4] }}</td>
                                    <td>{{ item[5] }}</td>
                                    <td>{{ item[6] }}</td>
                                    <td>{{ item[7] }}</td>
                                    <td>{{ item[8] }}</td>

                                </tr>
                                {% endfor %}
                            <tbody>
                        </table>
                        <!-- start 分页组件 -->
                        <div class="pagination">
                            <a href="#movie" class="active" id="page1"
                                onclick="goToPage(1, 'page1'); return false;">1</a>
                            <a href="#movie" id="page2" onclick="goToPage(2, 'page2'); return false;">2</a>
                            <a href="#movie" id="page3" onclick="goToPage(3, 'page3'); return false;">3</a>
                            <a href="#movie" id="page4" onclick="goToPage(4, 'page4'); return false;">4</a>
                            <a href="#movie" id="page5" onclick="goToPage(5, 'page5'); return false;">5</a>
                            <a href="#movie" id="page6" onclick="goToPage(6, 'page6'); return false;">6</a>
                            <a href="#movie" id="page7" onclick="goToPage(7, 'page7'); return false;">7</a>
                            <a href="#movie" id="page8" onclick="goToPage(8, 'page8'); return false;">8</a>
                            <a href="#movie" id="page9" onclick="goToPage(9, 'page9'); return false;">9</a>
                            <a href="#movie" id="page10" onclick="goToPage(10, 'page10'); return false;">10</a>
                        </div>
                        <!-- end 分页组件 -->
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- ====== END GET READY ====== -->

    <!-- ====== START FOOTER ======  -->
    <section class="footer">
        <div class="container">
            <div class="row">
                <!-- START MULTIMAX -->
                <div class="col-lg-4 col-md-6 mb-sm-5 mb-3">
                    <h3 class="heading-tertiary mb-3">Multimax</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id quos ipsa, soluta eum itaque nobis
                        quas sunt suscipit aliquid.</p>
                </div>
                <!-- END MULTIMAX -->

                <!-- START QUICK LINKS -->
                <div class="col-lg-2 col-md-6 mb-sm-5 mb-3">
                    <h3 class="heading-tertiary mb-3">Quick Links</h3>
                    <ul>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Blog</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">About Us</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Our story</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Forum</a>
                        </li>
                    </ul>
                </div>
                <!-- END QUICK LINKS -->

                <!-- START SUPPORT -->
                <div class="col-lg-2 col-md-6 mb-sm-5 mb-3">
                    <h3 class="heading-tertiary mb-3">Support</h3>
                    <ul>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">FAQ'S</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Privacy</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Policy</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Support</a>
                        </li>
                        <li><i class="fa fa-angle-double-right"></i>
                            <a href="#0">Documetation</a>
                        </li>
                    </ul>
                </div>
                <!-- END SUPPORT -->

                <!-- START NEWSLETTER -->
                <div class="col-lg-4 col-md-6 mb-sm-5 mb-3">
                    <h3 class="heading-tertiary mb-3">Subscribe to our Newsletter</h3>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.Id nobis
                        quas sunt suscipit aliquid.</p>
                    <form class="form mt-3">
                        <div class="form-check mb-3"> <label class="form-check-label"> <input type="checkbox"
                                    name="checkbox">
                                <small>Yes, I would like to receive communications by email.
                                </small></label>
                        </div>
                        <div class="input-group">
                            <input name="email" type="email" class="form-control" placeholder="Enter your email"
                                required>
                            <button class="btn" type="submit"><i class="fa fa-paper-plane"></i></button>
                        </div>
                    </form>
                </div>
                <!-- END NEWSLETTER -->

                <hr class="clearfix w-100 color-dark">

                <!-- START FOOTER BOTTOM -->
                <div class="offset-md-3 col-md-6 offset-md-3">

                    <!-- START SOCIAL ICONS -->
                    <div class="social-links">
                        <ul>
                            <li><a href="#0"><i class="fa fa-facebook fa-fw"></i></a></li>
                            <li><a href="#0"><i class="fa fa-twitter fa-fw"></i></a></li>
                            <li><a href="#0"><i class="fa fa-linkedin fa-fw"></i></a></li>
                            <li><a href="#0"><i class="fa fa-pinterest-p fa-fw"></i></a></li>
                            <li><a href="#0"><i class="fa fa-instagram fa-fw"></i></a></li>
                        </ul>
                    </div>
                    <!-- END SOCIAL ICONS -->

                    <!-- START RIGHTS -->
                    <div class="copyright">
                        <h5> &copy; The Garden of Eden 2024 | All Rights Reserved. </h5>
                    </div>
                    <!-- END RIGHTS -->
                </div>
                <!-- END FOOTER BOTTOM -->
            </div>
        </div>
    </section>
    <!-- ====== END FOOTER ======  -->

    <!-- ====== JS ======  -->
    <!--jquery-3.3.1 js-->
    <script src="../static/js/jquery-3.3.1.min.js"></script>

    <!-- popper js -->
    <script src="../static/js/popper.min.js"></script>

    <!-- bootstrap js -->
    <script src="../static/js/bootstrap.min.js"></script>

    <!-- scrollIt js -->
    <script src="../static/js/scrollIt.min.js"></script>

    <!-- countTo js -->
    <script src="../static/js/jquery.countTo.js"></script>

    <!-- filter js -->
    <script src="../static/js/jquery.filterizr.min.js"></script>

    <!-- waypoints js -->
    <script src="../static/js/waypoints.min.js"></script>

    <!-- Magnific Popup core JS -->
    <script src="../static/js/jquery.magnific-popup.min.js"></script>

    <!-- owl carousel js -->
    <script src="../static/js/owl.carousel.min.js"></script>

    <!-- validator js -->
    <script src="../static/js/validator.js"></script>

    <!-- coustom js -->
    <script src="../static/js/main.js"></script>

    <script>
        function goToPage(page, label) {
            // 在这里添加页面跳转逻辑，例如跳转到相应的 URL
            console.log('Go to page', page, 'with label', label);

            // 移除之前的活动样式
            var activePage = document.querySelector('.pagination .active');
            if (activePage) {
                activePage.classList.remove('active');
            }

            // 设置当前点击的页码为活动样式
            var currentPage = document.getElementById('page' + page);
            if (currentPage) {
                currentPage.classList.add('active');
            }

            getData(page - 1)
        }

        function getData(page) {
            // 点击按钮时发起 AJAX 请求

            $.ajax({
                url: '/get_data',
                type: 'GET',
                data: { 'page': page },
                success: function (newData) {

                    // 清空旧数据
                    $('.table tbody').empty();
                    // 更新页面内容
                    for (var i = 0; i < newData.length; i++) {
                        $('.table tbody').append('<tr>' +
                            '<td>' + newData[i][0] + '</td>' +
                            '<td><a href="' + newData[i][1] + '">' + newData[i][3] + '</a></td>' +
                            '<td>' + newData[i][4] + '</td>' +
                            '<td>' + newData[i][5] + '</td>' +
                            '<td>' + newData[i][6] + '</td>' +
                            '<td>' + newData[i][7] + '</td>' +
                            '<td>' + newData[i][8] + '</td>' +
                            '</tr>');
                    }

                },
                error: function (error) {
                    console.log('Error:', error);
                }
            });

        }

    </script>
</body>

</html>